<?php namespace Home\Controller; 
use Hdphp\Controller\Controller;
//前台默认控制器
class IndexController extends Controller{
    //前台首页
    public function index(){
    	//1.循环出来最新4篇文章
		$arcModel = new \Common\Model\Arc;
		$arcData = $arcModel->join('category','category_cid','=','cid')->orderBy('sendtime','DESC')->where("is_recycle=0")->limit(4)->get();
		//2.实例化中间表,把对应每篇文章的标签压入进去
		$arctagModel = new \Common\Model\ArcTag;
		foreach ($arcData as $k => $v) {
			$arcData[$k]['tag'] = $arctagModel->join('tag','tag_tid','=','tid')->where("article_aid={$v['aid']}")->field('tid,tname')->get();

		}
		//分配数据
		View::with('arcData',$arcData);
    	//载入模板
       View::make();
    }

}
